﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ComponentFactory.Krypton.Toolkit;
using BotonJXC.Entity;
using System.ComponentModel;

namespace BotonJXC.Forms
{
    public class BaseForm : ComponentFactory.Krypton.Toolkit.KryptonForm
    {
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            this.BackColor = System.Drawing.SystemColors.GradientInactiveCaption;
        }
        protected void SetWarehouseValue(KryptonComboBox comboBox, Warehouse warehouse)
        {
            if (warehouse != null)
            {
                SetWarehouseValue(comboBox, warehouse.WarehouseId);
            }
        }
        protected void SetWarehouseValue(KryptonComboBox comboBox, int warehouseId)
        {
            IList<Warehouse> list = comboBox.Tag as IList<Warehouse>;
            if (list != null)
            {
                foreach (Warehouse w in list)
                {
                    if (w.WarehouseId == warehouseId)
                    {
                        comboBox.SelectedItem = w;
                        break;
                    }
                }
            }
        }
        protected void SetStoreValue(KryptonComboBox comboBox, Store store)
        {
            if (store != null)
            {
                SetStoreValue(comboBox, store.StoreId);
            }
        }
        protected void SetStoreValue(KryptonComboBox comboBox, int storeId)
        {
            IList<Store> list = comboBox.Tag as IList<Store>;
            if (list != null)
            {
                foreach (Store s in list)
                {
                    if (s.StoreId == storeId)
                    {
                        comboBox.SelectedItem = s;
                        break;
                    }
                }
            }
        }
        protected void SetDepValue(KryptonComboBox comboBox, Department dep)
        {
            if (dep != null)
            {
                SetDepValue(comboBox, dep.DepId);
            }
        }
        protected void SetDepValue(KryptonComboBox comboBox, int depId)
        {
            IList<Department> list = comboBox.Tag as IList<Department>;
            if (list != null)
            {
                foreach (Department d in list)
                {
                    if (d.DepId == depId)
                    {
                        comboBox.SelectedItem = d;
                        break;
                    }
                }
            }
        }

        protected void SetToolStripItemEnabled(bool enabled, params ToolStripItem[] items)
        {
            foreach (ToolStripItem i in items)
                i.Enabled = enabled;
            
        }
    }
}